<template>
  <el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
    <el-form-item label="单据" prop="docno">
  <el-input v-model="formData.docno" name="docno" clearable />
</el-form-item>
<el-form-item label="变动类型" prop="trans_type">
  <el-input v-model="formData.trans_type" name="trans_type" clearable />
</el-form-item>
<el-form-item label="品号" prop="material_no">
  <el-input v-model="formData.material_no" name="material_no" clearable />
</el-form-item>
<el-form-item label="原始库位" prop="from_location">
  <el-input v-model="formData.from_location" name="from_location" clearable />
</el-form-item>
<el-form-item label="原始箱号" prop="from_lotnum">
  <el-input v-model="formData.from_lotnum" name="from_lotnum" clearable />
</el-form-item>
<el-form-item label="原始计量单位" prop="from_unit">
  <el-input v-model="formData.from_unit" name="from_unit" clearable />
</el-form-item>
<el-form-item label="变动数量" prop="qty">
  <el-input v-model="formData.qty" name="qty" clearable />
</el-form-item>
<el-form-item label="目标库位" prop="to_location">
  <el-input v-model="formData.to_location" name="to_location" clearable />
</el-form-item>
<el-form-item label="目标箱号" prop="to_lotnum">
  <el-input v-model="formData.to_lotnum" name="to_lotnum" clearable />
</el-form-item>
<el-form-item label="目标单位" prop="to_unit">
  <el-input v-model="formData.to_unit" name="to_unit" clearable />
</el-form-item>
<el-form-item label="创建时间" prop="created_at">
  <el-input v-model="formData.created_at" name="created_at" clearable />
</el-form-item>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '/admin/composables/curd/useCreate'
import { useShow } from '/admin/composables/curd/useShow'
import { onMounted } from 'vue'

const props = defineProps({
  primary: String | Number,
  api: String,
})

const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)

if (props.primary) {
  useShow(props.api, props.primary, formData)
}

const emit = defineEmits(['close'])
onMounted(() => {
  close(() => emit('close'))
})
</script>
